//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

using ProjectBase.Core;
using ProjectBase.Core.Web;
using ProjectBase.Mvc;
using ProjectBase.Mvc.Controllers;

using $prjsn$.Common;
using $prjsn$.Common.Models;
using $prjsn$.Common.Controllers;
using $prjsn$.Common.Business;
using $prjsn$.Entity;

namespace $safeprojectname$.Controllers
{
    /// <summary>
    /// All actions for CustomListType
    /// </summary>
    public class CustomListTypeController : CodeListController<CustomListType, CustomListTypeFilter, ICustomListTypeModel, ICustomListTypeFacade>, ICustomListTypeController
    {
        /// <summary>List View</summary>
        protected override IEnumerable<IItemToDisplay> LoadItemsToDisplay(CustomListTypeFilter filter)
        {
            return Facade.Find(filter)
                .Select(i => new ItemToDisplay()
                {
                    ID = i.IDToDisplay,
                    Description = i.ToDisplay(),
                    Items = new List<ICellDescription>
                    {
                        i.Cell(e => e.Description),
                        i.Cell(e => e.ID, new CellDescription {Align = Align.right, Format = "N0"}),
                    }
                } as IItemToDisplay);
        }
        /// <summary>Excel</summary>
        protected override IEnumerable<IEnumerable<IExCell>> LoadExcelItemsToDisplay(CustomListTypeFilter filter)
        {
            return Facade.Find(filter)
                .Select(i => new List<IExCell>
                {
                    i.ExCell(e => e.ID),
                    i.ExCell(e => e.Description),
                });
        }
        /// <summary>Filter defaults</summary>
        protected override CustomListTypeFilter ClearFilter()
        {
            var filter = base.ClearFilter();
            
            filter.IsVisible = true;
            // TODO set the MVC defaults e.g.: filter.OrderBy["ID"] = false;
            return filter;
        }

        public override string ControllerName { get { return Str.Controllers.CustomListType; } }
    }
}
